package com.sy.utils;

import com.alibaba.druid.pool.DruidDataSource;

import javax.sql.DataSource;
import java.util.Properties;

public class JdbcUtils {
    private static Properties dbProps;
    private static DruidDataSource ds;

    private JdbcUtils() {

    }

    static {
        dbProps = PropertiesUtils.loadClassPathProperties("db.properties");
        //创建数据源对象
        ds = new DruidDataSource();
        ds.setDriverClassName(dbProps.getProperty("driverClassName"));
        ds.setUrl(dbProps.getProperty("url"));
        ds.setUsername(dbProps.getProperty("user"));
        ds.setPassword(dbProps.getProperty("pwd"));
    }

    public static DataSource getDataSource() {
        return ds;
    }


}
